<?php
// 本类由系统自动生成，仅供测试用途
namespace Admin\Controller;
use Think\Controller;
class CommentController extends BaseController {
    public function index(){
		$this->display();
    }
      // 设置查看评论页面
    public function checkComment(){
    	$this->init();
    	$this->commentList();
		$this->display();
    }
     // 设置管理评论页面
     public function manageComment(){
    	$this->init();
		$this->display();
    }
    
    // 评论列表
    public function commentList(){

        if(isset($_POST['keyword'])){
            $username=I('post.keyword');
            $data['username']=array('like','%'.trim($username).'%');
        }
        if(isset($_POST['time']) && $_POST['time']!=""){
            $t = strtotime(I('post.time'));
            // 时间段
            // 本月时间开始结束
            // 当天时间开始结束
            // $month_end=mktime(23,59,59,date("m",$t),date("t",$t),date("Y",$t));
            // $month_end=date("Y-m-d H:i:s",mktime(23,59,59,date("m",$t),date("t",$t),date("Y",$t)));
            // $today_start=date("Y-m-d H:i:s",mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t)));
            // $today_end=date("Y-m-d H:i:s",mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t)));
            $beginToday=mktime(0,0,0,date('m',$t),date('d',$t),date('Y',$t));
            $endToday=mktime(0,0,0,date('m',$t),date('d',$t)+1,date('Y',$t))-1;
            $data['time']=array('between',array($beginToday,$endToday));
        }
        $comment=M('comment');
        $commentList =$comment->where($data)->select();
        $this->assign('commentList',$commentList);
    }
      // 删除评论
    public function deleteComment(){
        $comment=M('comment');
        $deleteComment=$comment->where('id='.$_GET['id'])->delete();
        if($deleteComment){
            $this->success("删除成功",U("Comment/checkComment"));
        }else{
            $this->error('删除失败');
        }
    }
}